package com.example.demo2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_listview);
        ListView listView = findViewById(R.id.list);

        //数据
        String[] data={"计算机导论","高等数学","高等物理","计算机导论"};

        ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.simple_list_item,data);

        listView.setAdapter(adapter);

    }
}